package snucse.teamd;

import java.util.List;
import java.util.Vector;

import snucse.teamd.math.Vec2;

public class SubTriangle {

	List<Vec2> tvertices;
	Vec2 com;
	double radiusOfBoundingCircle;

	public SubTriangle(List<Vec2> vertices)
	{
		tvertices = vertices;
		setCenterOfMass();
		setRadiusOfBoundingCircle();
		
	}
	private void setCenterOfMass()
	{
		int n = tvertices.size();
		double x = 0f;
		double y = 0f;
		for(int i=0; i<n; i++)
		{
			Vec2 temp = tvertices.get(i);
			x += temp.getX();
			y += temp.getY();
		}
		
		com = new Vec2(x/n, y/n);
	}
	private void setRadiusOfBoundingCircle()
	{
		radiusOfBoundingCircle = 0f;
		for(int i = 0; i < tvertices.size(); i++)
		{
			double temp = Vec2.distance(tvertices.get(i), com);
			if(radiusOfBoundingCircle < temp)
			{
				radiusOfBoundingCircle = temp;
			}
		}
	}
	public Vec2 getCom() {
		return com;
	}
	public void setCom(Vec2 com) {
		this.com = com;
	}
	public List<Vec2> getTvertices() {
		return tvertices;
	}
	public void setTvertices(List<Vec2> tvertices) {
		this.tvertices = tvertices;
	}
	
	
}
